home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / hypercrd / xcmds / dvlprstc.hqx / Developer Stack 1.3r / card_11574.txt < prev    next >
Text File  |  1991-04-30  |  2KB  |  110 lines

  1. -- card: 11574 from stack: in.3r
  2. -- bmap block id: 0
  3. -- flags: 4000
  4. -- background id: 3837
  5. -- name: RenameFile
  6.  
  7.  
  8. -- part 2 (button)
  9. -- low flags: 00
  10. -- high flags: A004
  11. -- rect: left=202 top=233 right=282 bottom=265
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 27056 / 27056
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Try It
  20. ----- HyperTalk script -----
  21. --
  22. --12/15/87  ΓÇóΓÇóΓÇóSteve DrazgaΓÇóΓÇóΓÇó
  23. --
  24. --This script needs XFCNs 'FilenName' and 'RenameFile'
  25. --It also needs the Hypertalk function 'LastPathComponent'
  26. --It also needs the Hypertalk subroutine 'OsErr'
  27. --
  28. on mouseUp
  29.   if the optionkey is down then pass mouseup
  30.   put "Please select a file to rename"
  31.   put filename() into renamethis
  32.   if renamethis is empty then
  33.     hide message window
  34.     play oops
  35.     exit mouseup
  36.   end if
  37.   hide message window
  38.  
  39.   put LastPathComponent(renamethis) into shortname
  40.   ask "What do you want to name this file" with shortname
  41.   if it is shortname or it is empty then
  42.     hide message window
  43.     play oops
  44.     exit mouseup
  45.   end if
  46.  
  47.   put RenameFile(renamethis,it) into returnedthis
  48.  
  49.   if returnedthis = 0 then
  50.     answer "Everything went just fine"
  51.   else
  52.     if returnedthis < 0 then
  53.       OsErr returnedthis
  54.     else
  55.       play oops
  56.       answer "Whoops, there was an error"
  57.     end if
  58.   end if
  59. end mouseUp
  60.  
  61.  
  62.  
  63. -- part contents for background part 5
  64. ----- text -----
  65. RenameFile
  66.  
  67. -- part contents for background part 10
  68. ----- text -----
  69. 8
  70.  
  71. -- part contents for background part 6
  72. ----- text -----
  73.  
  74. This will change the name of a file.
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. Thanks to:
  82. Dewi Williams
  83. 2227 Juniper Court
  84. Boulder CO 80302
  85. (303) 443 9038
  86. Delphi: DEWI
  87.  
  88.  
  89. -- part contents for background part 7
  90. ----- text -----
  91. Syntax:
  92.  
  93. RenameFile (<OldName>,<NewName>)
  94.  
  95. Returns either 0 (meaning a successful operation), 1 (meaning a parameter error), or a negative number (representing an operating system error).
  96.  
  97.  
  98. "OldName" is a full pathname of the file that you want to rename.
  99.  
  100. "NewName" is a replacement for the last component of the path.
  101.  
  102. Do not put quotation marks around 
  103. "OldName" and "NewName"
  104.  
  105.  
  106. You can use the OsErr* XCMD to interpret operating system errors.
  107.  
  108. -- part contents for background part 27
  109. ----- text -----
  110. XFCN